812f924c056001e218ff4b34e8d9e8f7b9db7edb,textdb/textdb-dataflow/src/test/java/edu/uci/ics/textdb/dataflow/regexmatch/RegexMatcherTest.java,RegexMatcherTest,testRegexText3,#,269

Before Change


    @Test
    public void testRegexText3() throws Exception {
        List<ITuple> data = RegexTestConstantsText.getSampleTextTuples();
        RegexMatcherTestHelper testHelper = new RegexMatcherTestHelper(RegexTestConstantsText.SCHEMA_TEXT, data);

        String regex = "([a-zA-Z])+o[a-z]a[a-z]o";
        testHelper.runTest(regex, RegexTestConstantsText.CONTENT, true);

        List<ITuple> exactResults = testHelper.getResults();

        List<ITuple> expectedResults = new ArrayList<ITuple>();

        // expected to match "Tomato" & "tomato"
        Schema spanSchema = testHelper.getSpanSchema();
        List<Span> spans = new ArrayList<Span>();
        spans.add(new Span(RegexTestConstantsText.CONTENT, 0, 6, regex, "Tomato"));
        spans.add(new Span(RegexTestConstantsText.CONTENT, 94, 100, regex, "tomato"));
        IField spanField = new ListField<Span>(new ArrayList<Span>(spans));
        List<IField> fields = new ArrayList<IField>(data.get(7).getFields());
        fields.add(spanField);
        expectedResults.add(new DataTuple(spanSchema, fields.toArray(new IField[fields.size()])));

        // expected to match "Potato"
        spans.clear();
        spans.add(new Span(RegexTestConstantsText.CONTENT, 0, 6, regex, "Potato"));
        spanField = new ListField<Span>(new ArrayList<Span>(spans));
        fields = new ArrayList<IField>(data.get(8).getFields());
        fields.add(spanField);
        expectedResults.add(new DataTuple(spanSchema, fields.toArray(new IField[fields.size()])));

        // expected to match "avocado"
        spans.clear();
        spans.add(new Span(RegexTestConstantsText.CONTENT, 53, 60, regex, "avocado"));
        spanField = new ListField<Span>(new ArrayList<Span>(spans));
        fields = new ArrayList<IField>(data.get(9).getFields());
        fields.add(spanField);
        expectedResults.add(new DataTuple(spanSchema, fields.toArray(new IField[fields.size()])));

        Assert.assertTrue(TestUtils.equals(expectedResults, exactResults));

        testHelper.cleanUp();
    }

    @Test

After Change



    @Test
    public void testRegexText3() throws Exception {
        String query = "([a-zA-Z])+o[a-z]a[a-z]o";
        List<ITuple> exactResults = RegexMatcherTestHelper.getQueryResults(
                TEXT_TABLE, query, Arrays.asList(RegexTestConstantsText.CONTENT));
        
        List<ITuple> expectedResults = new ArrayList<ITuple>();

        // expected to match "Tomato" & "tomato"
        List<ITuple> data = RegexTestConstantsText.getSampleTextTuples();
        Schema spanSchema = Utils.addAttributeToSchema(RegexTestConstantsText.SCHEMA_TEXT, SchemaConstants.SPAN_LIST_ATTRIBUTE);
        List<Span> spans = new ArrayList<Span>();
        spans.add(new Span(RegexTestConstantsText.CONTENT, 0, 6, query, "Tomato"));
        spans.add(new Span(RegexTestConstantsText.CONTENT, 94, 100, query, "tomato"));